package com.sgb.kjwl.view.widget.manage

import android.text.InputFilter
import android.text.Spanned
import android.text.TextUtils

/**
 * emoji表情过滤
 */
class EmojiExcludeFilter : InputFilter {
    override fun filter(
        source: CharSequence?,
        start: Int,
        end: Int,
        dest: Spanned?,
        dstart: Int,
        dend: Int
    ): CharSequence? {
        if (TextUtils.isEmpty(source)){
            return null
        }
        for (i in start until end) {
            val type: Int = Character.getType(source!![i])
            if (type == Character.SURROGATE.toInt() || type == Character.OTHER_SYMBOL.toInt()) {
                return ""
            }
        }
        return null
    }
}